package org.hxyjs;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.Reader;

public class Test {
    /**
     * 启动MyBatis去加载配置文件 1.java.io.Reader 2.Resources 3.SqlSessionFactory
     */
    private static Reader reader;
    private static SqlSessionFactory sqlSessionFactory;

    static {
        try {
            reader = Resources.getResourceAsReader("mybatis.xml");//读取指定的配置文件 生成jdbc等mybatis需要的数据库信息
            sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);//根据读取的信息构造一个mybatis的工厂类
        } catch (IOException e) {
            e.printStackTrace();
        }
    }


}
